/// 带返回值
fn plus_one(a: i32) -> i32 {
    a + 1
}

/// 函数可以作为一个参数
pub fn test() {
    let x = 2;
    let p1: fn(i32) -> i32 = plus_one;
    let y = p1(x);

    println!("{} plus one is {}", x, y);

    let x = 2;
    let square = |i: i32| -> i32 {
        i * i
    };
    println!("the square of {} is {}", x, square(x));
}
